package com.fjec.market.schedule.handler;

import com.fjec.market.service.IBizPhysicalOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Component
@Slf4j
public class RequestPhyDivideHandler {

    @Resource
    private IBizPhysicalOrderService bizPhysicalOrderService;

    public String handle(int limit, int minutes) {
        List<Map<String, Object>> ordersToDivide = bizPhysicalOrderService.getOrdersToDivide(limit, minutes);
        if (ordersToDivide.size() == 0)
            return "no orders to divide";
        bizPhysicalOrderService.writePhyDistributionInfo(ordersToDivide);
        return "success";
    }
}
